package com.yumhai.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yumhai.system.mapper.VersionManageMapper;
import com.yumhai.system.service.VersionManageService;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.model.entity.sys.VersionInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class VersionManageServiceImpl implements VersionManageService {

    @Resource
    private VersionManageMapper versionManageMapper;

    public void addVersionInfo(VersionInfo versionInfo) throws Exception {
        versionManageMapper.insert(versionInfo);
        return;
    }


    public IPage getVersionPagination(PaginationVo paginationVo) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<VersionInfo> lqs = new LambdaQueryWrapper<>();
        lqs.orderByDesc(VersionInfo::getCreateTime);
        versionManageMapper.selectPage(page, lqs);

        return page;
    }
}
